package fuzzylizard.teamdocs.web;

import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;

import wicket.RestartResponseAtInterceptPageException;


public abstract class SecuredBasePage extends TeamdocsPage {

    private Log log = LogFactory.getLog(SecuredBasePage.class);
    
    public SecuredBasePage() {
        super();
        verifyAccess();
    }
    
    protected void verifyAccess() {
        if (!isUserLoggedIn()) {
            log.debug("User is not logged in. Redirecting to login page");
            throw new RestartResponseAtInterceptPageException(Login.class);
        }
    }

    protected boolean isUserLoggedIn() {
        log.debug("isUserLoggedIn()");
        return getTeamdocsSession().loggedIn();
    }
}
